package jdk8.lambda;

public abstract class Animal {

	private String name;
	
	public Animal() {
		this.name = "未知动物名";
	}

	public Animal(String name) {
		this.name = name;
	}
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	public abstract void eat();

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Animal [name=").append(name).append("]");
		return builder.toString();
	}

	public int compareByName(Animal other) {
		//
		return this.name.compareTo(other.name);
	}
	
}
